package com.zsh.myserver.sample.database;

import com.zsh.myserver.sample.dao.IDataBaseConnect;
import com.zsh.myserver.sample.dao.MySQLController;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * Copyright (C), 2020-2020
 * Author: Zhoushaohua
 * Date: 2020/4/4 12:01
 * Description: 连接MySQL的配置类
 */
@Configuration
public class MySQLConfiguration {
    /**
     * 所有的配置字段均在配置类中进行动态的赋值
     *
     * @Value 为什么能读取到application.properties中配置的值
     */

    @Value("${mysql.ip}")
    private String ip;
    @Value("${mysql.port}")
    private Integer port;

    @Bean
    public IDataBaseConnect getMySqlController() {
        return new MySQLController(this.ip, this.port);
    }
}
